﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace prjKQXS_DLL
{
    public partial class frmNhapSL : DevExpress.XtraEditors.XtraForm
    {
        private string frmName = string.Empty;
        private string ma_dt = string.Empty;
        private DungChung2_DAL dungchung2 = new DungChung2_DAL();
        public frmNhapSL(string m_caption, string label, string button, string textBox, Boolean isPass)
        {
            InitializeComponent();
            this.Text = m_caption;
            this.frmName = "";
            this.ma_dt = textBox;
            lblThongbao.Text = label;
            sbtnLoc.Text = button;
            txtTen.Text = "";
            if (isPass)
            {
                txtTen.Properties.PasswordChar = Convert.ToChar("*");
                chkPass.Visible = true;
            }
        }
        public frmNhapSL(string frmName, string m_caption, string label, string button, string textBox, Boolean isPass)
        {
            InitializeComponent();
            this.Text = m_caption;
            this.frmName = frmName;
            this.ma_dt = label;
            lblThongbao.Text = label;
            sbtnLoc.Text = button;
            txtTen.Text = textBox;
            if (isPass)
            {
                txtTen.Properties.PasswordChar = Convert.ToChar("*");
                chkPass.Visible = true;
            }

        }
        public string retVal = "";
        private void sbtnLoc_Click(object sender, EventArgs e)
        {
            if (frmName == "DVTINH")
            {
            dungchung2.insertTen_dt(ma_dt, txtTen.Text);
            }
            retVal = txtTen.Text.Trim();
            this.Close();
        }

        private void frmNhapSL_Load(object sender, EventArgs e)
        {            
            if (frmName == "DVTINH")
            {
                lblThongbao.Text = "Mã đơn vị này chưa có trong danh mục. Nhập vào tên để ghi vào danh mục !";
                string ten_dt = txtTen.Text;
             //   dungchung2.insertTen_dt(ma_dt, ten_dt);
             //   this.Close();
            }
            else
            {
                retVal = "";
            }
        }

        private void sbtnBoqua_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void chkPass_CheckedChanged(object sender, EventArgs e)
        {
            if (chkPass.Checked)
            {
                txtTen.Properties.PasswordChar = Convert.ToChar("\0");
            }
            else
            {
                txtTen.Properties.PasswordChar = Convert.ToChar("*");
            }
        }
        protected override void OnShown(EventArgs e)
        {
            this.txtTen.Focus();
            base.OnShown(e);
        }
    }
}